<template>
  <div>
    <swiper>
      <swiper-item v-for="(item, id) in banners" :key="id">
        <a :href="item.link">
          <img :src="item.image" alt="" @load='imgLoaded' />
        </a>
      </swiper-item>
    </swiper>
  </div>
</template>

<script>
import { Swiper, SwiperItem } from "components/common/swiper/";
export default {
  name: "HomeSwiper",
  props: {
    banners: {
      type: Array
    }
  },
  data() {
    return {
      isLoaded: false
    }
  },
  components: {
    Swiper,
    SwiperItem,
  },
  methods:{
    imgLoaded(){
      if(!this.isLoaded){
        // console.log('hello')
        this.$emit('swiperImgLoaded')
        this.isLoaded = true
      }
    }
  }
};
</script>